package com.mzpai.web.controller;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.mzpai.product.constant.ProductConstants;
import com.mzpai.product.exception.ProductResExceptionCode;
import com.mzpai.product.model.ContractTemplate;
import com.mzpai.product.service.ContractTemplateService;
import com.mzpai.vo.ResponseVo;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
/**
 *
 * <b>商品品牌 | Controller</b><br>
 *
 * yanglijun 2021-03-16 18:48:49
 * 
 *  @version 1.0.0
 *
 */
@Api(value = "店铺商品数据接口")
@RestController
@RequestMapping("/contractTemplateController")
public class ContractTemplateController extends BaseController {

	@Autowired 
	private ContractTemplateService contractTemplateService;
	private static Logger log = LoggerFactory.getLogger(ContractTemplateController.class);
	
	@ApiOperation(value = "查询合同协议模板")
    @RequestMapping(value = "/queryContractTemplate",method = {RequestMethod. POST ,RequestMethod. GET })
    public ResponseVo<ContractTemplate> queryContractTemplate(@RequestParam(value = "templateNum", required = true) String templateNum){
		
		log.info("msg1=开始查询合同协议模板,,method=queryContractTemplate,,templateNum={}",templateNum);
		Map<String,Object> queryMap=new HashMap<String,Object>();
		queryMap.put("templateStatus", ProductConstants.TEMPLATE_STATE1);
		queryMap.put("templateNum", templateNum);
		List<ContractTemplate> listContractTemplate=contractTemplateService.getList(queryMap);
		if(listContractTemplate==null || listContractTemplate.isEmpty()){
			ResponseVo resultVo=new ResponseVo();
			resultVo.setCode(ProductResExceptionCode.TEMPLATE_NULL.getCode());
			resultVo.setMessage(ProductResExceptionCode.TEMPLATE_NULL.getMessage());
			return resultVo;
		}
		ContractTemplate contractTemplate=listContractTemplate.get(0);
		ResponseVo<ContractTemplate> resVo=new ResponseVo<ContractTemplate>();
		resVo.setResult(contractTemplate);
		return resVo;
	}

	
	

}